home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
F1 Licenseware
/
F1 Licenseware - Volume 1.iso
/
disks
/
055a.dms
/
055a.adf
/
colours.LHA
/
COLOURS.AMOS
/
COLOURS.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1980-01-05
|
8KB
|
222 lines
'******************************************************************
'* COLOUR PROCEDURES & DEMO PROG CODED BY ANDY DOBINSON FOR ISSUE *
'* 4 OF AMOSZINE, On 8 OCTOBER 1994 While I WAS BORED *
'* *
'* THIS PROGRAM IS NOT TO APPEAR ON ANY OTHER DISKMAG OTHER THAN *
'* AMOSZINE ISSUE 4 THE RESASON BEING IS THAT IM AM FED UP WITH *
'* SEEING THE SAME SOURCE CODE ON NEARLY EVERY AMOS DISKMAG AND *
'* TO BE HONEST ITS GETTING REDICULOUS, INFACT ONE DISKMAG THAT *
'* I GOT HOLD OF A FEW MONTHS AGO HAD THE ENTIRE SOURCE CODE ON *
'* IT FROM BRIAN BELLS MAC ISSUE 6 ,WHAT WAS THE POINT IN DOING *
'* THAT.? *
'******************************************************************
Unpack 10 To 0 : Unpack 11 To 1 : Screen 1
Shift Up 1,2,28,1 : Wait Vbl : Screen Open 2,640,8,2,Hires
Flash Off : Curs Off : Cls 0 : Colour 0,$0 : Colour 1,$FFF
Screen Display 2,128,54,640,7 : Pen 1 : Paper 0
Screen 2
Print " COLOUR PROCEDURE'S & DEMO PROG CODED BY ANDY DOBINSON FOR AMOSZINE ISSUE 4";
Screen Open 3,640,60,4,Hires : Screen Display 3,128,242,640,60
Flash Off : Curs Off : Cls 0
Colour 0,$0 : Colour 3,$FFF : Pen 3 : Paper 0 : Home
Print " Right first of all lets do some copper spreading using the copper"
Print " spread procedure. now those of you who have got issue 1 will know"
Print "that there was a procedure to do this anyway,but mine takes up a lot less code"
For T=0 To 10
Screen 0
A=Rnd(4095)
B=Rnd(4095)
_COPPER_SPREAD_[A,B,0,150,1,1]
Next T
_COPPER_SPREAD_[$F00,$FF0,0,150,1,1]
Screen 3
Cls 0 : Home
Print " PRESS ANY KEY "
Wait Key
Screen 3
Cls 0 : Home
Print " Now we have got our picture on screen we want to fade it"
Print " but first we must reserVe a palette bank using the palette"
Print " reserve procedure PRESS ANY KEY"
Wait Key
_RESERVE_AS_PALETTE_BANK_[9,10]
Cls 0 : Home : List Bank
Print " and as you can see there should a bank called DATA"
Print " PRESS A KEY "
Wait Key : Cls 0 : Home
Print " now lets send our palette to the bank using the _palette_to_bank"
Print " procedure and fade the screen as usual using the fade command"
Print " PRESS ANY KEY"
Screen 0
_PALETTE_TO_BANK_[9,1]
Wait Key
Screen 0 : Fade 3 : Wait 50
Screen 3 : Cls 0 : Home
Print " Right now lets fade in using the FADE_BANK_TO_SCREEN procedure"
Print " PRESS ANY KEY"
Wait Key : Screen 0
_FADE_BANK_TO_SCREEN_[9,1,5,0]
Screen 3 : Cls 0 : Home
Print " Now lets darken the screen using the DARKEN_SCREEN procedure"
Print " PRESS ANY KEY"
Wait Key : Screen 0
_DARKEN_SCREEN_[3,8,16]
Screen 3 : Cls 0 : Home
Print " and then restore the colours from the palette bank"
Print " PRESS ANY KEY"
Wait Key : Screen 0
_FADE_BANK_TO_SCREEN_[9,1,5,0]
' Before you use any of the following instructions..
' _PALETTE_FROM_BANK_
' _PALETTE_TO_BANK_
' _FADE_BANK_TO_SCREEN_
' You must first reserve a palette bank using the next procedure
'
Procedure _RESERVE_AS_PALETTE_BANK_[_BANK_NUMBER,NUMBER_OF_PALETTES]
Reserve As Data _BANK_NUMBER,2+(128*NUMBER_OF_PALETTES)
T$="Palette."
'Poke$ Start(_BANK_NUMBER)-8,Left$(T$,8)
Doke Start(_BANK_NUMBER),NUMBER_OF_PALETTES
End Proc
'
' this next procedure takes your current screen palette and
' and dokes it into the specified memory bank.
'
Procedure _PALETTE_TO_BANK_[_BANK_NUMBER,_PALETTE_NUMBER]
If Length(_BANK_NUMBER)<2 Then Pop Proc
If _PALETTE_NUMBER>Deek(Start(_BANK_NUMBER)) Then Pop Proc
A=(Screen Colour)-1
For T=0 To A
Doke Start(_BANK_NUMBER)+2+_PALETTE_NUMBER*64+T*2,Colour(T)
Next T
End Proc
'
' This next procedure allows you to extract a palette from
' from the specified bank to the current screen
'
Procedure _PALETTE_FROM_BANK_[_BANK_NUMBER,_PALETTE_NUMBER]
If Length(_BANK_NUMBER)<2 Then Pop Proc
If _PALETTE_NUMBER>Deek(Start(_BANK_NUMBER)) Then Pop Proc
A=(Screen Colour)-1
For T=0 To A
Colour T,Deek(Start(_BANK_NUMBER)+2+_PALETTE_NUMBER*64+T*2)
Next T
End Proc
'
' this next one allows you to spread a colour between two colour
' indexes just like the spread option in duluxe paint
' IT DOES NOT AFFECT ANY DATA HELD IN A PALETTE BANK
'
Procedure _COLOUR_SPREAD_[_COL1,_COL2]
If A=0 Then Dim RED(31),GREEN(31),BLUE(31) : A=1
For T=_COL1 To _COL2
RED(T)=(Colour(T)/256)
GREEN(T)=(Colour(T)/16 mod 16)
BLUE(T)=(Colour(T) mod 16)
Next T
For T=_COL1 To _COL2 Step Sgn(_COL2-_COL1)
RED(T)=RED(_COL1)+((RED(_COL2)-RED(_COL1))*(T-_COL1))/(_COL2-_COL1)
GREEN(T)=GREEN(_COL1)+((GREEN(_COL2)-GREEN(_COL1))*(T-_COL1))/(_COL2-_COL1)
BLUE(T)=BLUE(_COL1)+((BLUE(_COL2)-BLUE(_COL1))*(T-_COL1))/(_COL2-_COL1)
Colour T,RED(T)*256+GREEN(T)*16+BLUE(T)
Next T
End Proc
'
' This ones a bit simple, it just allows you to swap two colours
' around in the current screen.
' IT DOES NOT AFFECT ANY DATA HELD IN A PALETTE BANK
'
Procedure _COLOUR_SWAP_[_COL1,_COL2]
A=Colour(_COL1)
B=Colour(_COL2)
Colour _COL1,Colour(B)
Colour _COL2,Colour(A)
End Proc
'
' This next one allows you to darken the current screen
' very handy if you want to scroll text over it .
' IT DOES NOT AFFECT ANY DATA HELD IN A PALETTE BANK
'
Procedure _DARKEN_SCREEN_[SPEED,_STEPS,_NUMBER_OFF_COLOURS]
For G=0 To _STEPS
For T=0 To _NUMBER_OFF_COLOURS
RED=(Colour(T)/256)
GREEN=(Colour(T)/16 mod 16)
BLUE=(Colour(T) mod 16)
Add RED,-1
Add GREEN,-1
Add BLUE,-1
If RED<0 Then RED=0
If GREEN<0 Then GREEN=0
If BLUE<0 Then BLUE=0
Colour T,RED*256+GREEN*16+BLUE
Next T
Wait Vbl
Next G
End Proc
'
' xnow this one finds the brightest colour in the current
' screen palette, i've used the procedure that allows you to return
' a value so to use it do this
'
' _brightest_colour_
' ink Param
' or
' your variable = Param
'IT DOES NOT AFFECT ANY DATA HELD IN A PALETTE BANK
'
Procedure _BRIGHTEST_COLOUR_
A=0
E=0
B=Screen Colour-1
For C=0 To B
D=Colour(C)
If D>A Then E=C : A=D
Next C
End Proc[E]
'
' this one allows you to fade in your palette to the screen from
' a palette stored inthe specified bank.
'IT DOES NOT AFFECT ANY DATA HELD IN A PALETTE BANK
'
Procedure _FADE_BANK_TO_SCREEN_[_BANK_NUMBER,_PALETTE_NUMBER,_SPEED,_SCREEN]
D=Screen Colour
Screen Open 7,16,16,D,L
Screen Hide 7
Flash Off
Screen 7
If Length(_BANK_NUMBER)<2 Then Pop Proc
If _PALETTE_NUMBER>Deek(Start(_BANK_NUMBER)) Then Pop Proc
A=D-1
For T=0 To A
Colour T,Deek(Start(_BANK_NUMBER)+2+_PALETTE_NUMBER*64+T*2)
Next T
Screen _SCREEN
Fade _SPEED To 7
Wait _SPEED*15
Screen Close 7
End Proc
Procedure _COPPER_SPREAD_[_COL1,_COL2,_START,_END,_RAIN_NUM,_COLOUR_INDEX]
If A=0 Then Dim RED(255),GREEN(255),BLUE(255) : A=1
Set Rainbow _RAIN_NUM,_COLOUR_INDEX,255,"","",""
RED(_END)=(_COL2/256) : GREEN(_END)=(_COL2/16 mod 16) : BLUE(_END)=(_COL2 mod 16)
RED(_START)=(_COL1/256) : GREEN(_START)=(_COL1/16 mod 16) : BLUE(_START)=(_COL1 mod 16)
For T=_START To _END
RED=RED(_START)+((RED(_END)-RED(_START))*(T-_START))/(_END-_START)
GREEN=GREEN(_START)+((GREEN(_END)-GREEN(_START))*(T-_START))/(_END-_START)
BLUE=BLUE(_START)+((BLUE(_END)-BLUE(_START))*(T-_START))/(_END-_START)
Rain(_RAIN_NUM,T)=RED*256+GREEN*16+BLUE
Next T
Rainbow _RAIN_NUM,0,40,245
Wait Vbl
End Proc